#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#define Max (1024 * 1024)
#define PHY_MEM 256
int main(){
	char *a_memory;
	int megabyte_obtained=0;
	size_t size_to_allocate=Max;
	while(megabyte_obtained<(PHY_MEM*2)){
	a_memory=(char *)malloc(size_to_allocate);
	if (a_memory!=NULL)
	{
		megabyte_obtained++;
		sprintf(a_memory,"Hello world ");
		printf("%s - now allocated %d Mega\n",a_memory,megabyte_obtained);
	
        
	}
	else{
		exit(EXIT_FAILURE);
	}
	}
	exit(EXIT_SUCCESS);
}
